#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
//#define int long long
//#define lc p<<1
//#define rc p<<1|1
//#define lowbit(x) x&-x
#define endl putchar('\n')
#define psp putchar(' ')
using namespace std;
const int N=1e6+5;
const int M=1e3+5;
int n,m,k;
int T;
int money;
int level=1;
string es[N];
string cs[N];
int nigger;
int scavenger;
int day;
int randomplayer[10]={0,1,0,1,0,1,0,0,1,0};
int randomnigger[10]={0,0,0,1,0,0,0,0,0,0};
int lottery1[100];
int happen;
string elst[N];
string clst[N];
int cnt;
void init(){
	es[1]="beg";cs[1]="乞讨";
	es[2]="buy a nigger";cs[2]="购买黑奴";
	es[3]="buy a lottery 1";cs[3]="购买一类彩票";
	es[4]="hire a scavenger";cs[4]="雇佣拾荒者";
}
int lang;
void check(){
	system("cls");
	for(int i=1;i<=cnt;i++){
		if(lang==2)cout<<i<<'.'<<elst[i];
		else cout<<i<<'.'<<clst[i];
	}
	if(cnt==0){
		if(lang==2)cout<<"There is nothing here.\n";
		else cout<<"这里什么也没有。\n";
	}
	if(lang==2)cout<<"【s】 to continue\n";
	else cout<<"按【s】建继续\n";
	char op=getch();
	while(op!='s')op=getch();
}
int searching[N];
signed main(){
	//ios::sync_with_stdio(0);
	init();
	lottery1[50]=100;
	lottery1[48]=lottery1[12]=lottery1[31]=20;
	lottery1[1]=lottery1[7]=lottery1[87]=lottery1[23]=lottery1[32]=5;
	srand(time(0));
	cout<<"1.简体中文\n2.English\nChoose language(选择语言):";
	cin>>lang;
	while(lang!=1&&lang!=2){
		system("cls");
		cout<<"1.简体中文\n2.English\nChoose language(选择语言):";
		cin>>lang;
	}
	while(1){
		happen=0;
		if(level<=1&&money>=5)level=2,elst[++cnt]="slave trade\n",clst[cnt]="奴隶贸易\n";
		if(level<=2&&money>=10)level=3,elst[++cnt]="lottery\n",clst[cnt]="彩票\n";
		if(level<=3&&money>=35)level=4,elst[++cnt]="scavenger\n",clst[cnt]="拾荒\n";
		system("cls");
		if(lang==2)cout<<"day: "<<day<<"  Your money: "<<money<<"$\n";
		else cout<<"天数: "<<day<<"  资金: "<<money<<"$\n";
		if(level>1){
			if(lang==2)cout<<"Your nigger:"<<nigger<<'\n';
			else cout<<"黑奴数量："<<nigger<<'\n';
		}
		for(int i=1;i<=level;i++){
			if(lang==2)cout<<i<<"."<<es[i]<<'\n';
			else cout<<i<<"."<<cs[i]<<'\n';
		}
		if(lang==2)cout<<"s.check achievement\n";
		else cout<<"s.查看成就\n";
		char op=getch();
		while(op-'0'>level&&op!='s'&&op!=' ')op=getch();
		int niggermade=0;
		for(int i=1;i<=nigger;i++){
			int x=rand()%10;
			int made=0;
			if(randomnigger[x])made+=rand()%4+1;
			money+=made;
			niggermade+=made;
		}
		if(nigger>0&&niggermade>0){
			if(lang==2)cout<<"nigger get "<<niggermade<<"$ by beg\n";
			else cout<<"黑奴通过乞讨得到了 "<<niggermade<<"$\n";
			happen++;}
		for(int i=1;i<=scavenger;i++){
			if(searching[i]==10){
				searching[i]=0;
				int made=rand()%10+20;
				if(lang==2)cout<<"scavenger get "<<made<<"$ by searching\n";
				else cout<<"拾荒者通过拾荒赚取了 "<<made<<"$\n";
				money+=made;
			}
		}
		if(op==' '){
			day++;
			Sleep(1000);
			continue;
		}
		if(op=='s'){
			check();
		}
		if(op=='1'){
			int x=rand()%10;
			int made=0;
			if(randomplayer[x]){
				made+=rand()%6+1;
			}
			money+=made;
			if(lang==2)cout<<"Done,you made "<<made<<"$\n";
			else cout<<"你得到了 "<<made<<"$\n";
			happen++;
		}
		if(op=='2'){
			if(money>=5){
				money-=5;
				nigger++;
				happen++;
				if(lang==2)cout<<"buy 1 nigger\n";
				else cout<<"买了一个黑奴\n";
			}
			else{
				if(lang==2)cout<<"You have no money!\n";
				else cout<<"你没钱了\n";
				Sleep(800);
			}
		}
		if(op=='3'){
			if(money>=10){
				money-=10;
				int made=lottery1[rand()%100];
				money+=made;
				happen++;
				if(lang==2)cout<<"You win "<<made<<"$\n";
				else cout<<"你通过彩票得到了 "<<made<<"$\n";
			}
			else{
				if(lang==2)cout<<"You have no money!\n";
				else cout<<"你没钱了\n";
				Sleep(800);
			}
		}
		if(op=='4'){
			if(money>=35){
				money-=35;
				scavenger++;
				happen++;
				if(lang==2)cout<<"hire 1 scavenger\n";
				else cout<<"雇佣了一名拾荒者\n";
			}
			else{
				if(lang==2)cout<<"You have no money!\n";
				else cout<<"你没钱了\n";
				Sleep(800);
			}
		}
		if(happen){
			day++;
			for(int i=1;i<=scavenger;i++)searching[i]++;
			Sleep(1200*happen);
		}
	}
}
